<template>
  <div class="dashboard-editor-container">
    <panel-group/>

    <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <line-chart/>
    </el-row>

    <div class="over">
      <div class="qrcode-btn">
        <el-button type="primary" @click="generateQrcode">生成安卓二维码</el-button>
      </div>
      <div class="qrcode" v-if="qrcode">
        <div class="qrcode-image">
          <img :src="qrcode">
        </div>
        <el-button @click="saveQrcode" size="small">保存</el-button>
      </div>
    </div>

    <el-row :gutter="32" style="display: none">
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <raddar-chart/>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart/>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <bar-chart/>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import GithubCorner from '@/components/GithubCorner'
import PanelGroup from './components/PanelGroup'
import LineChart from './components/LineChart'
import RaddarChart from './components/RaddarChart'
import PieChart from './components/PieChart'
import BarChart from './components/BarChart'
import { generateQrcode } from '@/api/business/games'

export default {
  name: 'DashboardAdmin',
  components: {
    GithubCorner,
    PanelGroup,
    LineChart,
    RaddarChart,
    PieChart,
    BarChart
  },
  data() {
    return {
      qrcode: null,
    }
  },
  methods: {
    // 生成二维码
    generateQrcode() {
      generateQrcode().then(res=>{
        this.qrcode = res.data;
      })
    },
    // 保存二维码
    saveQrcode() {
      window.open(this.qrcode, "_blank")
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}
.over{
  overflow: hidden;
}
.qrcode-btn{
  float: left;
}
.qrcode-image{
  margin-bottom: 10px;
}
.qrcode{
  float: left;
  margin-left: 20px;
  text-align: center;
}
</style>
